cmake_minimum_required(VERSION 3.10)

project(fake_mem_pool)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)

include_directories(include)
link_directories(./)

# Build static libraries
add_library(mem_pool STATIC mem_pool.c)

# Build C example
add_executable(c_example c_example.c)
target_link_libraries(c_example mem_pool)

# Build C++ example
add_executable(cpp_example cpp_example.cpp)
target_link_libraries(cpp_example mem_pool)

# Set output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

# Clean target
add_custom_target(clean_all
    COMMAND ${CMAKE_BUILD_TOOL} clean
    COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/build
    COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin
    COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/lib
)
